<?php
/**
 * 模板模式
 * This file is part of pattern.
 * Author: tangzhou
 * Date: 2016/9/22
 * Time: 14:22
 * File: Template.php
 */

abstract class MakePhone
{
    public $name;
    function __construct($name)
    {
        $this->name = $name;
    }

    function make()
    {
        $this->makeScreen();
        $this->makeCamera();
        echo $this->name.'生产完毕';
    }
    abstract public function makeScreen();
    abstract public function makeCamera();
}

class NokiaPhone extends MakePhone
{
    public function __construct($name)
    {
        parent::__construct($name);
    }

    public function makeScreen()
    {
        echo "nokia屏幕生产完毕";
    }

    public function makeCamera()
    {
        echo "nokia相机生产完毕";
    }
}

class XiaoMiPhone extends MakePhone
{
    public function __construct($name)
    {
        parent::__construct($name);
    }

    public function makeScreen()
    {
        echo "xiaomi屏幕生产完毕";
    }

    public function makeCamera()
    {
        echo "xiaomi相机生产完毕";
    }
}

$mi = new XiaoMiPhone("红米");
$mi->make();

$nokia = new NokiaPhone("5020");
$nokia->make();